using System;
using System.Collections.Generic;
using System.Data;
using System.Text;

namespace T.FAS.Runtime.Excel.Dao
{
    public static class ToolUtil
    {
        public static string GetDateDiff(DateTime dt)
        {
            TimeSpan span = DateTime.Now - dt;
            if (span.TotalDays >= 30)
            {

                return T.ServiceComponent.I18N.Service.TermService.Current.GetTextFormatted("T_FAS_fasr_Excel_549284082", "{0}月前", (int)Math.Floor(span.TotalDays / 30));
            }
            else if (span.TotalDays >= 7)
            {
                return T.ServiceComponent.I18N.Service.TermService.Current.GetTextFormatted("T_FAS_fasr_Excel_310347304", "{0}周前", (int)Math.Floor(span.TotalDays / 7));
            }
            else if (span.TotalDays >= 1)
            {
                return T.ServiceComponent.I18N.Service.TermService.Current.GetTextFormatted("T_FAS_fasr_Excel_1370110342", "{0}天前", (int)Math.Floor(span.TotalDays));
            }
            else if (span.TotalHours >= 1)
            {
                return T.ServiceComponent.I18N.Service.TermService.Current.GetTextFormatted("T_FAS_fasr_Excel_1568206226", "{0}小时前", (int)Math.Floor(span.TotalHours));
            }
            else if (span.TotalMinutes >= 1)
            {
                return T.ServiceComponent.I18N.Service.TermService.Current.GetTextFormatted("T_FAS_fasr_Excel_1385299872", "{0}分钟前", (int)Math.Floor(span.TotalMinutes));
            }
            else
            {
                return T.ServiceComponent.I18N.Service.TermService.Current.GetText("T_FAS_fasr_Excel_1482651760", "刚刚");
            }
        }
        public static Dictionary<string, object> GetTaskList<T>(Dictionary<string, object> dic, List<T> result, DataSet totalds)
        {
            int total = 0;
            if (totalds?.Tables.Count > 0)
            {
                total = totalds.Tables[0].Rows.Count;
            }
            dic.Add("state", "1");
            dic.Add("data", result);
            dic.Add("total", total);
            return dic;
        }
    }
}